import {createApp} from 'vue'
import ElementPlus, {ElDialog} from 'element-plus';
import 'element-plus/lib/theme-chalk/index.css';

import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'

import '@/theme/index.scss'
import tabs from "@/tabs";
import App from "@/App.vue";

// 默认不显示关闭按钮
ElDialog.props.showClose.default = false;
ElDialog.props.closeOnPressEscape.default = false;
ElDialog.props.closeOnClickModal.default = false;


/**
 * 应用配置
 */
export declare interface AppConfig {
    /**
     * 系统Logo
     */
    logo: string | Promise<typeof import("*.png")>

    /**
     * 是否需要登录
     */
    needLogin: boolean,

    /**
     * 自定义标签页
     */
    tabs: Record<string, unknown>

}


/**
 * 启动应用
 * @param config 应用配置
 */
function bootstrap(config: AppConfig) {

    // 合并tab配置
    Object.assign(tabs, config.tabs);

    // 创建应用
    const rootProp = {...config};
    const app = createApp(App, rootProp);

    app.use(ElementPlus, {size: 'mini'})
    app.use(VXETable, {size: 'mini'})
    app.mount('#app')
}

export default bootstrap;
